<!--是否全屏显示-->
<template>
  <a-icon :type="isFullscreen ? 'fullscreen-exit' : 'fullscreen'" title="全屏显示" @click="Fullscreen" />
</template>

<script>
import screenfull from 'screenfull'
export default {
  name: '',
  components: {},
  data () {
    return {
      isFullscreen: false // 是否全屏
    }
  },
  created () {},
  mounted () {
    this.init()
  },
  methods: {
    // 是否全屏函数
    Fullscreen () {
      if (!screenfull.isEnabled) {
        this.$message({
          message: 'you browser can not work',
          type: 'warning'
        })
        return false
      }
      screenfull.toggle()
    },
    change () {
      this.isFullscreen = screenfull.isFullscreen
    },
    init () {
      if (screenfull.isEnabled) {
        screenfull.on('change', this.change)
      }
    },
    destroy () {
      if (screenfull.isEnabled) {
        screenfull.off('change', this.change)
      }
    }
  }
}
</script>
<style lang="less" scoped>
</style>
